import * as THREE from "../../../modules/three/three.module.js";

export const IsoTolerance = {
  phi: 2,
  theta: 2,
  span: 0.5,
}
export const IsoEnum = {
  phi: 'phi',  // 等俯仰角线 Symbol()
  theta: 'theta', // 等方位角线
  none: 'none', // 无类型
}
export default class IsoLineVO {
  name = ''
  /**
   * 由局部切平面（法向采样点）序列组成的等值线
   * @type {NormalPointVO[]}
   */
  normalPoints = []
  /**
   * 等值线类型
   * @see IsoEnum
   * @type {string}
   */
  isoType = IsoEnum.none

  constructor(isoType) {
    this.isoType = isoType
  }

  // true 为纬线等值线
  isPhi() {
    return this.isoType === IsoEnum.phi
  }
  // true 为经线等值线
  isTheta() {
    return this.isoType === IsoEnum.theta
  }
  toJsonObj() {
    const obj = {isoType: this.isoType, name: this.name}
    obj.points = this.normalPoints.map(it => it.id)
    return obj
  }
  fromJsonObj(jsonObj, allNormalPoints) {
    this.name = jsonObj.name
    this.isoType = jsonObj.isoType
    this.normalPoints = jsonObj.points.map(id => allNormalPoints.find(nPt => nPt.id === id))
    return this
  }
}
